//
//  MineLevelViewController.m
//  LiveStar
//
//  Created by 漪珊 on 2017/4/14.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "MineLevelViewController.h"
#import "PrivilegesCell.h"

@interface MineLevelViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@property (weak, nonatomic) IBOutlet UIImageView *levelIcon;
@property (weak, nonatomic) IBOutlet UILabel *level;
@property (weak, nonatomic) IBOutlet UILabel *experienceValue;
@property (weak, nonatomic) IBOutlet UILabel *upgradeValue;
@property (weak, nonatomic) IBOutlet UILabel *fastUpgradeMethod;

@end

@implementation MineLevelViewController
static NSString *privilegesCellID = @"privilegesCellID";
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"我的等级";
    [self setUpUI];
}

- (void)setUpUI {
    self.fastUpgradeMethod.text = @"1   观看直播可以获得发展值\n\n2   礼物刷的越多，升级越快\n\n3   分享、点赞、发言互动都涨发展值哦";
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    self.collectionView.collectionViewLayout = flowLayout;
    [self.collectionView registerNib:[UINib nibWithNibName:@"PrivilegesCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:privilegesCellID];
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return 5;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    PrivilegesCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:privilegesCellID forIndexPath:indexPath];
    if (indexPath.row == 4) {
       cell.starLevel.text = @"敬请期待";
    } else {
        cell.starLevel.text = [NSString stringWithFormat:@"%ld级开启",(long)indexPath.row+1];
    }
    if (indexPath.row == 0) {
        cell.privilIcon.image = kSET_IMAGE(@"privileges_1");
    } else if (indexPath.row == 4) {
        cell.privilIcon.image = kSET_IMAGE(@"more_privileges");
    } else {
        NSString *imgName = [NSString stringWithFormat:@"privileges_%ld_normal",(long)indexPath.row+1];
        cell.privilIcon.image = kSET_IMAGE(imgName);
        
    }
    switch (indexPath.row) {
        case 0:
            cell.privilDetailLabel.text = @"等级彰显";
            break;
        case 1:
            cell.privilDetailLabel.text = @"专属礼物";
            break;
        case 2:
            cell.privilDetailLabel.text = @"入场特效";
            break;
        case 3:
            cell.privilDetailLabel.text = @"私信畅聊";
            break;
        case 4:
            cell.privilDetailLabel.text = @"更多特权";
            break;
            
        default:
            break;
    }
    return cell;
}

- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    return CGSizeMake(49, 90);
}

- (UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(0, 20, 0, 20);
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
